package org.sy.lab.多线程基础._3_同步辅助类._4_Phaser阶段器;

import java.util.concurrent.Phaser;

public class MyPhaser extends Phaser {
	
	public MyPhaser(int parties) {
        super(null, parties);
    }
	
	@Override
	protected boolean onAdvance(int phase, int registeredParties) {
		switch (phase) {
		case 0:
			System.out.println("火箭第1阶段就绪，就绪部件数量：" + registeredParties + "\n");
			return false;
		case 1:
			System.out.println("火箭第2阶段就绪，就绪部件数量：" + registeredParties + "\n");
			return false;
		case 2:
			System.out.println("火箭第3阶段就绪，就绪部件数量：" + registeredParties + "\n");
			System.out.println("火箭升空\n");
			return false;
		default:
			return true;
		}
	}
}
